import 'package:flutter/material.dart';
import 'pages/index_page.dart';
import 'package:provide/provide.dart';
import './provide/child_category.dart';
import './provide/category_goods_list.dart';
import './provide/details_info.dart';
import './provide/currentIndex.dart';
import './routes/routes.dart';
import './routes/application.dart';
import 'package:fluro/fluro.dart';
import './provide/cart.dart';
import './provide/person.dart';
import './provide/setting.dart';

void main(){
  var providers = Providers();
  var childCategory= ChildCategory();
  var categoryGoodsListProvide= CategoryGoodsListProvide();
  var detailInfoProvide = DetailsInfoProvide();
  var cartProvide = CartProvide();
  var currentIndex = CurrentIndexProvide();
  var person = PersonnalProvider();
  var setting = SettingProvide();
  providers
    ..provide(Provider<CategoryGoodsListProvide>.value(categoryGoodsListProvide))
    ..provide(Provider<PersonnalProvider>.value(person))
    ..provide(Provider<SettingProvide>.value(setting))
    ..provide(Provider<DetailsInfoProvide>.value(detailInfoProvide))
    ..provide(Provider<CartProvide>.value(cartProvide))
    ..provide(Provider<CurrentIndexProvide>.value(currentIndex))
    ..provide(Provider<ChildCategory>.value(childCategory));
    
  runApp(ProviderNode(child:MyApp(),providers:providers));
}

class MyApp extends StatelessWidget {
  final Widget child;

  MyApp({Key key, this.child}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final router = Router();
    Routes.configureRoutes(router);
    Application.router=router;
    return Provide<SettingProvide>(
      builder: (context,child,val){
        return MaterialApp(
          title: '百姓生活',
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            primaryColor: val.themeColor
          ),
          home: IndexPage(),
        );
      },
    );
  }
}